package main

import (
	. "GO_data_structures_and_algorithms/tool"
	"fmt"
	"sort"
)

func main() {

	students := Students{
		&Student{
			Name: "rrrr",
			Id:   8,
			Age:  1,
		},
		&Student{
			Name: "aaa",
			Id:   1,
			Age:  1,
		},
		&Student{
			Name: "bbb",
			Id:   1,
			Age:  2,
		}, &Student{
			Name: "ccc",
			Id:   2,
			Age:  5,
		},
		&Student{
			Name: "ddd",
			Id:   3,
			Age:  2,
		},
	}
	ss := []*Student{
		&Student{
			Name: "rrrr",
			Id:   8,
			Age:  1,
		},
		&Student{
			Name: "aaa",
			Id:   1,
			Age:  1,
		},
		&Student{
			Name: "bbb",
			Id:   1,
			Age:  2,
		}, &Student{
			Name: "ccc",
			Id:   2,
			Age:  5,
		},
		&Student{
			Name: "ddd",
			Id:   3,
			Age:  2,
		},
	}
	sort.Sort(students)
	for _, v := range students {
		fmt.Printf("%+v\n", v)
	}
	sort.Slice(ss, func(i, j int) bool {
		if ss[i].Id != ss[j].Id {
			return ss[i].Id < ss[j].Id
		}

		return ss[i].Age < ss[j].Age
	})
	for _, v := range ss {
		fmt.Printf("%+v\n", v)
	}
}
